The present invention relates to combining an antialiased foreground image with a background image. It finds particular application in conjunction with combining the images using a chroma key, and will be described with particular reference thereto. It will be appreciated, however, that the invention is also amenable to other like applications.
The concept of inserting a person or subject into a background scene to form a composite image has been practiced in the motion picture industry as far back as the 1930""s. bver the years, improvements have been made in image compositing. However, it is a complex and difficult process.
In the motion picture industry, the foreground and background scenes are photographed on film. The film is subsequently scanned to produce high definition red-green-blue (xe2x80x9cRGBxe2x80x9d) signals for computer assisted image compositing. In the compositing process, the colored backing is replaced with a background scene so that the foreground subject and the background scene appear as a single image.
A chroma-key method of compositing video images for television switches between a foreground subject, which is placed before a constant colored (commonly blue) backing, and a background scene, which is based on the presence or absence of the hue of the backing. Today""s chroma-key systems (even with a soft edge) still switch between the foreground and background scenes.
Either-or selection is satisfactory for television newscasts when the subject is opaque and has well-defined edges. However, it is less satisfactory for television, and is totally unacceptable for motion pictures, when the subject includes loose hair, fog, smoke, motion blur, glassware, window reflections, out-of-focus objects, and other semi-transparent subjects. In these subjects, both the foreground and background elements occupy the same area and, therefore, there is no appropriate place to switch.
To properly reproduce these semi-transparent areas requires a xe2x80x9cmixingxe2x80x9d concept as opposed to the xe2x80x9ceither-orxe2x80x9d concept of a switch. Composite methods based upon the xe2x80x9cmixingxe2x80x9d concept do not switch between the foreground and background scenes. Instead, the background scene is added to the foreground scene as a linear function of the luminance and visibility of the colored backing. The colored backing is removed by subtraction.
Until now, chroma-key has most commonly been an analog process, if the foreground image is a natural image, and a digital process if the foreground image is a synthetic image. In the synthetic case it is common to compute a separate coverage mask indicating which pixels are in the foreground and which are in the background, with intermediate values in the mask for pixels that are partially covered by the foreground. When the image is not computer generated, this approach is not available unless the mask is somehow computed as a separate step. In either case, the normal practice for digital compositing is to linearly blend the foreground pixel colors with the background pixel colors when computing new pixels along the edge, with the blending coefficient being given by the coverage. This may lead to artifacts when the background image contains structure that is partially covered by the foreground portion of the pixel of interest.
The present invention provides a new and improved apparatus and method which overcome the above-referenced problems and others.
A foreground scene is composited with a background scene by evaluating each of a plurality of foreground pixels in the foreground scene. For each of the foreground pixels, a determination is made if the foreground pixel is included within an edge between a subject and a backing in the foreground scene. The backing includes a key color. If the foreground pixel is included within the edge, the foreground pixel is scaled up into a plurality of foreground subpixels. A background pixel, at a corresponding location in the background scene, is scaled up into a plurality of background subpixels. A determination is made, for each of the foreground subpixels, if a color of the foreground subpixel matches the key color. If the foreground subpixel matches the key color, the foreground subpixel is replaced with a corresponding background subpixel. After determining if each of the foreground subpixels matches the key color, the foreground subpixels are scaled down to a corresponding new foreground pixel.
In accordance with one aspect of the invention, if the foreground pixel is not included within the edge, a determination is made if a color of the foreground pixel is the key color. If the color of the foreground pixel is the key color, the foreground pixel is replaced with a corresponding background pixel for forming the corresponding new foreground pixel.
In accordance with a more limited aspect of the invention, if the foreground pixel has been replaced, the new corresponding foreground pixel is written to a composite scene stored in a memory. If the foreground pixel has not been replaced, the foreground pixel is written to the composite scene in the memory.
In accordance with an even more limited aspect of the invention, the composite scene is output to a color output device.
In accordance with another aspect of the invention, the foreground subpixels are scaled down by determining an average color of the foreground subpixels. The new foreground pixel is created to include the average color.
In accordance with another aspect of the invention, the determination of whether the foreground pixel is included within the edge includes identifying a neighborhood of pixels including the foreground pixel.
In accordance with another aspect of the invention, the foreground and background pixels are scaled up to a same scale.
One advantage of the present invention is that it provides a chroma-key technique suitable for use with digital images.
Another advantage of the present invention is that it provides a smooth edge around antialiased objects in a foreground image that is composited with a background image using a chroma-key technique.
Still further advantages of the present invention will become apparent to those of ordinary skill in the art upon reading and understanding the following detailed description of the preferred embodiments.